local skel = fk.CreateSkill{
  name = "#sj_dianjuren__lihuaqingxie_choose",
}

Fk:loadTranslationTable{
  ["#sj_dianjuren__lihuaqingxie_choose"] = "礼花倾泻",
}

skel:addEffect("active", {
  prompt = "#sj_dianjuren__lihuaqingxie_ask",
  target_filter = Util.FalseFunc,
  expand_pile = function (self, player)
    return self.extra_data.cards or {}
  end,
  card_filter = function (self, player, to_select, selected, selected_targets)
    if #selected > 2 or not (table.contains(player:getCardIds("h"),to_select) or table.contains(self.extra_data.cards or {},to_select)) then return false end
    if #selected > 0 then
      local types,suit = {},{}
      for _, id in ipairs(selected) do
        local card = Fk:getCardById(id)
        table.insertIfNeed(types,card.type)
        table.insertIfNeed(suit,card.suit)
      end
      local card = Fk:getCardById(to_select)
      if #selected > 1 and #suit == 1 and #types == 1 then
        return card.suit == suit[1]
      end
      return (#suit == 1 and card.suit == suit[1]) or not table.contains(types,card.type)
    end
    return true
  end,
  feasible = function (self, player, selected, selected_cards, card)
    return #selected_cards == 3
  end,
})

return skel